import React, { useEffect } from 'react'
import PubSub from 'pubsub-js'

import Father1 from './components/Father1'
import Father2 from './components/Father2'
export default function App() {
  useEffect(() => {
    // 订阅消息
    let fanfanId= PubSub.subscribe('fanfan', (msg, data) => {
      console.log('----- App 组件 -----')
      console.log("msg: ",msg)
      console.log("data: ",data)
      console.log('----- App End -----')
    })

    return () => {
      // 取消订阅
      PubSub.unsubscribe(fanfanId)
    }
  }, [])
  return (
    <div>
      <Father1 />
      <hr />
      <Father2 />
    </div>
  )
}
